/* eslint-disable react/prop-types */
import React from 'react';
import {withRouter} from 'react-router-dom';
import '../../mysite.scss';
import Title from '@/components/mysite/titleWithBack'
import RoleForm from './form';
import Access from './access'

class RoleDetail extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            type:null,
            title:''
        }
    }
    componentDidMount(){
        let query = this.props.location.state
        let title;
        if (query) {
            if(query.type){
                title = '角色授权'
                this.setState({type:true})
            }else {
                title = '修改角色信息'
            }
        } else {
            title = '新建角色'
        }
        this.setState({title})
    }

    render() {
        const {type,title} = this.state;
        return (
        <div className="detail_page">
            <Title title={title}/>
            <div className="detail_form">
                {type?<Access/>:<RoleForm/>}
            </div>
        </div>
    )
    }
}

export default withRouter(RoleDetail)
